//若按照题意，这才是真正的正确做法。但是因为题目数据问题，反而只有40pts

#include <iostream>
#include <cstdio>

using namespace std;

int red = 15;
long long a = 0/*甲*/, b = 0/*乙*/; 

void f(int scr/*球多少分*/, int i/*第i次击球*/, int who/*甲0乙1*/){
    if(scr == 0){
        if(who == 0){//甲
            a += 4;
        }else{
            b += 4;
        }
    }else if(scr == 1) { // red ball
        if(i & 1){ // 第奇数次击球
            red--;
            if(who == 0)    a++;
            else            b++;
        }
    }
    else{  // color ball
        if((i & 1) && red){ //wrong
            if(scr > 4){
                if (who == 0)   b += scr;
                else            a += scr;
            }
            else{
                if (who == 0)   b += 4;
                else            a += 4;
            }
        }
        else{
            if (who == 0)   a += scr;
            else            b += scr;
        }
    }
}

int main(){
    int n, m, tmp;
    cin >> n >> m;
    //甲
    for(int i = 1; i <= n; i++){
        scanf("%d", &tmp);
        f(tmp, i, 0);
    }
    //乙
    for(int i = 1; i <= m; i++){
        scanf("%d", &tmp);
        f(tmp, i, 1);
    }
    printf("%lld %lld", a, b);
    return 0;
}
